Commentary - pseudo code

Commentary - pseudo code

The code below is a pseudo code for the Commentary plugin, which incorporates some of the tips and recommendations from the Commentary plugin page.
Use the pseudo code below as a starting point for a custom Commentary plugin.

 

CommentaryPseudoCode

 

package com.oracle.determinations.interview.engine.userplugins.commentary;

import com.oracle.determinations.interview.engine.InterviewSession;
import com.oracle.determinations.interview.engine.exceptions.UnsupportedException;
import com.oracle.determinations.interview.engine.plugins.InterviewSessionPlugin;
import com.oracle.determinations.interview.engine.plugins.InterviewSessionRegisterArgs;
import com.oracle.determinations.interview.engine.plugins.commentary.CommentaryProviderPlugin;
import com.oracle.determinations.interview.util.TypedInputStream;

public class PseudoCommentary implements CommentaryProviderPlugin {

              //REQUIRED - for Plugin Architecture
              public PseudoCommentary()
              {

              }

              //If the target is not redirect - return the commentary content for the 'target'
              public TypedInputStream getCommentaryContent(InterviewSession session, String target) {
                            TypedInputStream commentContent = null;
                            String fulltarget = session.getLocale() + "/" + target;

                            //Retrieve data using fulltarget e.g. from datasource
                            //Format data to HTML if needed

                            return commentContent;
              }

              //If the target is a redirect - return the URL commentary page for the 'target'
              public String getCommentaryURL(InterviewSession session, String target) {
                            String fulltarget = session.getLocale() + "/" + target;

                            //Retrieve URL or data to build URL using fulltarget e.g. from datasource
                            //Build URL from data if needed
                            //Return URL
              }

              //Return true if the commentary for the 'target' is available
              public boolean hasCommentary(InterviewSession session, String target) {
                            String fulltarget = session.getLocale() + "/" + target;

                            //Use fulltarget to check if commentary for target exists
                            //return true or false
              }

              // Return true if the commentary for this Web Determinations Interview is available
              public boolean isCommentaryEnabled(InterviewSession session) {

              }

              // Return true if the target is a redirect, i.e. uses URL for commentary. Otherwise return false
              public boolean isCommentaryRedirect(InterviewSession session, String target) {
                      String fulltarget = session.getLocale() + "/" + target;
                      //Use fulltarget to determine if the target is a redirect or not
              }

              //REQUIRED - for Plugin interface
              public InterviewSessionPlugin getInstance(InterviewSessionRegisterArgs args) {
                      return new RedirectCommentary();
              }
}